const next = require("next");
const express = require("express");
const { mode, port } = require("../env");
const app = next({ dev: mode === "dev" });
const handle = app.getRequestHandler();
const server = express();

app.prepare().then(() => {

	server.get("/blogs/:blogId", (req, res) => {
		return app.render(req, res, "/blog");
	});

	server.get("*", (req, res) => {
		return handle(req, res);
	});

	server.listen(port, () => {
		console.log(`App is running in ${port} !`);
	});
});